Skip to content

fix(lint/no-base-to-string): treat Symbol.toPrimitive methods as custom stringification - #1143

Merged
camc314 merged 1 commit into
mainfrom
fix/lint-no-base-to-string-to-primitive
Nov 29, 2026
Merged

camc314 merged 1 commit into
mainfrom
fix/lint-no-base-to-string-to-primitive

Conversation

@camc314

@camc314 camc314 commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Ports oxc-project/tsgolint#1398 to tsrs.

An object type that declares a [Symbol.toPrimitive] method defines its own coercion. The rule still fell back to Object's toString/valueOf and reported it:

declare const a: { [Symbol.toPrimitive](): string };
`${a}`; // reported as using Object's default stringification

Before checking toString, toLocaleString and valueOf, treat the type as always useful when one of its properties is a method signature keyed by Symbol.toPrimitive, where Symbol resolves to the default library. This matches tsgolint 7f5c22e5. The certainty helpers now take the program so they can run that library check. This refreshes the rule baseline to that commit and adds the upstream cases.

Validation: the no-base-to-string baseline (384 cases, 1 upstream skip), the no_base_to_string headless test, cargo clippy -p tsrs_lint --all-targets with warnings denied, and tools/lint/source.mjs.

Copilot AI balanced review requested due to automatic review settings November 29, 2026 16:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T18:56:11.722570Z 66a3c8c New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@camc314
camc314 force-pushed the fix/lint-no-base-to-string-to-primitive branch from 0e75fb0 to b1ee872 Compare November 29, 2026 16:58
@codspeed

codspeed Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

Warning

oxc-project has exceeded the Hobby plan limit of 5 active contributors. Upgrade your plan or apply to the open source program by December 8, 2026 to keep using CodSpeed.

1 warning

⚠️ 4 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 8 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing fix/lint-no-base-to-string-to-primitive (66a3c8c) with main (5784fad)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@camc314
camc314 force-pushed the fix/lint-no-base-to-string-to-primitive branch from b1ee872 to f927905 Compare November 29, 2026 17:24
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Performance change vs main

Workflow run · main 5784fadd39b2 → PR merge 5e4cf6212813 (head 66a3c8c8003d)

Clef gate: Running benchmarks because the decision was unavailable (crates/tsrs_lint/src/rules/no_base_to_string.rs: patch exceeds the Clef context limit (9485 bytes)).

Release builds in fast mode (TSRS_FAST=1) with Hyperfine 2 hardware counters. After warming each binary, alternating main/PR pairs measure wall time at both the fast preset's default checker count and with --singleThreaded, with ten pairs per configuration by default. Instructions come from the single-threaded runs; peak RSS comes from the default-count runs.
Incremental runs start with fresh build info before every invocation; check runs disable incremental compilation.

Project Mode Single-thread wall time Δ Single-thread instructions Δ Default wall time Δ Default peak RSS Δ
vscode check -0.4% 0.000% +0.2% +0.3%
vscode incremental 0.0% 0.000% +1.0% +0.2%
xstate-main check -0.6% 0.000% -1.3% +0.9%
xstate-main incremental +0.1% 0.000% -2.8% +0.6%
webpack check -0.9% -0.001% +1.3% +0.2%
webpack incremental +0.1% -0.001% -2.0% +0.3%
mui-docs check -0.1% -0.001% -0.7% +0.2%
mui-docs incremental -0.3% +0.011% -0.2% -0.2%
Compiler check +0.5% 0.000% -1.5% +1.9%
Compiler incremental 0.0% 0.000% -1.5% +1.5%
Compiler-Unions check +0.9% 0.000% +0.7% +0.7%
Compiler-Unions incremental -1.8% 0.000% -0.8% +0.1%
cal-diy check 0.0% -0.002% -0.3% -0.2%
cal-diy incremental +0.2% +0.003% +0.4% -0.1%
formbricks-web check +0.6% -0.001% +0.3% -0.1%
formbricks-web incremental -0.3% +0.001% -0.1% +0.1%
supabase-studio check +0.1% +0.002% +0.1% +0.1%
supabase-studio incremental -0.2% -0.002% +0.6% +0.1%
t3code-server check +0.3% +0.001% +0.4% -0.2%
t3code-server incremental -0.2% -0.003% +0.2% +0.2%
mikro-orm check +0.7% +0.001% +0.3% +0.2%
mikro-orm incremental +0.6% -0.001% +1.1% +0.1%
next-packages-next check -0.1% -0.001% -1.2% 0.0%
next-packages-next incremental +0.4% +0.004% -0.9% +0.6%
next-root check -0.4% -0.001% +0.6% +0.4%
next-root incremental +0.1% +0.001% -0.9% -0.2%
storybook check -0.5% -0.001% -1.5% -0.3%
storybook incremental +0.1% -0.002% -0.4% -0.1%
nuxt check -0.2% +0.001% 0.0% 0.0%
nuxt incremental -0.6% -0.001% -2.6% 0.0%
playwright check -0.7% -0.001% -1.0% -0.5%
playwright incremental -0.2% 0.000% -0.5% +0.1%
drizzle-orm check +0.1% 0.000% -1.7% -1.1%
drizzle-orm incremental -1.1% -0.001% -1.5% -0.2%
typeorm check -0.4% +0.002% +0.1% -0.2%
typeorm incremental +0.5% -0.002% -0.3% +0.1%
date-fns check +0.8% -0.003% -0.3% +0.8%
date-fns incremental +0.1% +0.004% -2.5% -0.1%
opencode-core check +0.1% -0.002% -0.1% -0.1%
opencode-core incremental -0.4% +0.006% +0.7% -0.1%
lobehub check -0.3% -0.001% -0.3% 0.0%
lobehub incremental -0.2% -0.002% -0.1% 0.0%
sentry check -0.3% +0.005% 0.0% 0.0%
sentry incremental -0.3% +0.001% +0.2% +0.1%

Negative means the PR used less; positive means it used more. Deltas are medians of paired PR/main ratios for wall time and instructions. Single-threaded runs reduce scheduling noise; shared CI machines can still add noise to wall time.

Measured medians (main → PR)
Project Mode Single-thread wall time (s) Single-thread instructions Default wall time (s) Default peak RSS (MiB)
vscode check 8.376 → 8.352 81,815,992,774 → 81,815,656,642.5 1.440 → 1.440 1800.2 → 1805.3
vscode incremental 8.503 → 8.495 84,217,783,287 → 84,217,900,797 1.640 → 1.645 2125.6 → 2130.3
xstate-main check 0.515 → 0.511 5,520,570,167 → 5,520,570,872.5 0.128 → 0.127 237.9 → 240.0
xstate-main incremental 0.535 → 0.533 5,679,444,759.5 → 5,679,493,020 0.165 → 0.162 240.6 → 241.9
webpack check 0.905 → 0.898 10,759,897,619.5 → 10,759,908,782 0.198 → 0.195 400.5 → 401.3
webpack incremental 0.940 → 0.943 10,980,235,716.5 → 10,980,210,775 0.242 → 0.239 398.8 → 399.9
mui-docs check 2.392 → 2.388 32,890,114,906.5 → 32,890,633,484.5 0.975 → 0.943 1184.5 → 1186.4
mui-docs incremental 2.531 → 2.525 34,220,346,285.5 → 34,224,002,519 1.105 → 1.099 1142.4 → 1140.4
Compiler check 0.139 → 0.139 1,745,225,332 → 1,745,226,440 0.063 → 0.062 75.9 → 77.4
Compiler incremental 0.139 → 0.139 1,759,527,096 → 1,759,524,444 0.064 → 0.064 78.3 → 79.4
Compiler-Unions check 0.199 → 0.199 3,014,353,396.5 → 3,014,352,008 0.092 → 0.092 80.2 → 80.7
Compiler-Unions incremental 0.200 → 0.197 3,026,973,657 → 3,026,962,519 0.094 → 0.093 83.5 → 83.7
cal-diy check 2.555 → 2.549 28,707,662,913.5 → 28,707,231,334.5 0.826 → 0.819 1338.4 → 1335.3
cal-diy incremental 2.748 → 2.755 30,308,116,717 → 30,308,405,946.5 1.041 → 1.042 1246.4 → 1244.8
formbricks-web check 3.323 → 3.334 36,891,985,649.5 → 36,892,089,316.5 0.864 → 0.866 1560.3 → 1559.2
formbricks-web incremental 3.632 → 3.630 39,473,846,223 → 39,474,339,890 1.106 → 1.099 1599.3 → 1600.1
supabase-studio check 3.619 → 3.604 40,538,392,379 → 40,539,446,981.5 0.899 → 0.901 1287.2 → 1289.0
supabase-studio incremental 3.853 → 3.844 43,471,209,477 → 43,470,464,770 1.036 → 1.033 1342.8 → 1343.8
t3code-server check 3.563 → 3.573 40,781,815,464.5 → 40,781,589,812.5 1.153 → 1.159 1301.8 → 1298.5
t3code-server incremental 3.635 → 3.623 41,291,770,604.5 → 41,290,357,751.5 1.428 → 1.434 1291.7 → 1293.6
mikro-orm check 3.977 → 3.993 44,046,968,237 → 44,047,895,476 0.825 → 0.830 1256.8 → 1258.9
mikro-orm incremental 4.020 → 4.042 44,356,665,142 → 44,355,879,447 0.932 → 0.943 1237.0 → 1238.4
next-packages-next check 1.446 → 1.442 17,278,104,472 → 17,277,941,307 0.361 → 0.356 551.7 → 552.0
next-packages-next incremental 1.529 → 1.538 17,588,973,526 → 17,589,611,908 0.453 → 0.453 554.2 → 557.8
next-root check 1.254 → 1.252 13,893,472,139 → 13,893,418,471 0.286 → 0.290 426.3 → 427.9
next-root incremental 1.234 → 1.236 14,349,895,277.5 → 14,350,300,612 0.319 → 0.317 467.5 → 466.4
storybook check 0.773 → 0.772 8,813,050,657 → 8,812,998,372 0.201 → 0.199 389.6 → 388.3
storybook incremental 1.281 → 1.631 9,132,468,546.5 → 9,132,203,673.5 0.240 → 0.239 369.1 → 368.7
nuxt check 0.826 → 0.824 8,428,786,929.5 → 8,428,920,020 0.218 → 0.218 385.9 → 385.8
nuxt incremental 0.867 → 0.863 8,824,893,775.5 → 8,824,900,993 0.235 → 0.232 384.8 → 384.8
playwright check 0.667 → 0.662 7,363,224,241.5 → 7,363,121,021 0.174 → 0.171 359.6 → 357.8
playwright incremental 0.689 → 0.687 7,539,494,303 → 7,539,550,333 0.190 → 0.188 336.7 → 337.0
drizzle-orm check 0.509 → 0.506 5,907,045,403 → 5,907,106,197.5 0.166 → 0.164 375.9 → 371.7
drizzle-orm incremental 0.541 → 0.536 6,075,981,020.5 → 6,076,091,565 0.181 → 0.183 340.5 → 339.8
typeorm check 0.580 → 0.579 6,344,278,958.5 → 6,344,341,791.5 0.131 → 0.132 224.6 → 224.2
typeorm incremental 0.634 → 0.636 6,728,604,274.5 → 6,728,501,669 0.174 → 0.176 229.5 → 229.8
date-fns check 0.273 → 0.274 3,297,407,342.5 → 3,297,360,094.5 0.081 → 0.084 148.8 → 150.0
date-fns incremental 0.303 → 0.304 3,530,981,085 → 3,531,305,106.5 0.099 → 0.098 161.7 → 161.5
opencode-core check 2.075 → 2.074 25,107,964,272 → 25,107,458,052 1.054 → 1.051 1185.2 → 1184.3
opencode-core incremental 2.150 → 2.145 25,468,249,592.5 → 25,469,359,055.5 1.089 → 1.093 1092.2 → 1091.5
lobehub check 16.655 → 16.618 185,336,381,110.5 → 185,333,835,239.5 5.616 → 5.582 4378.4 → 4378.0
lobehub incremental 16.997 → 16.941 188,894,602,708 → 188,897,126,154 6.955 → 6.944 4429.8 → 4429.4
sentry check 7.667 → 7.638 91,308,972,439.5 → 91,313,172,012 1.697 → 1.694 1750.8 → 1750.0
sentry incremental 7.826 → 7.789 93,270,288,346 → 93,270,137,808 2.163 → 2.039 1894.7 → 1896.7

tsrs-lint

Release tsrs-lint linting each project's source files with all 61 rules. After a warmup run of each binary, alternating main/PR pairs (10 per mode) measure wall time, CPU time and peak RSS with TSRS_FAST unset and with TSRS_FAST=1.

Project Mode Wall time Δ CPU time Δ Peak RSS Δ Diagnostics (main → PR)
webpack default 0.0% -0.2% 0.0% 35405, identical
webpack TSRS_FAST=1 -0.7% -1.1% 0.0% 35405, identical
drizzle-orm default -1.0% -0.1% 0.0% 7057, identical
drizzle-orm TSRS_FAST=1 -0.5% -0.9% -0.1% 7057, identical
xstate-main default -1.4% -0.5% +0.1% 6489, identical
xstate-main TSRS_FAST=1 -1.4% -0.5% -0.3% 6489, identical

Negative means the PR used less. Wall and CPU time deltas are medians of paired PR/main ratios; peak RSS compares medians.

Measured lint medians (main → PR)
Project Mode Wall time (s) CPU time (s) Peak RSS (MiB)
webpack default 0.362 → 0.364 1.853 → 1.848 454.4 → 454.3
webpack TSRS_FAST=1 0.361 → 0.357 1.870 → 1.856 454.9 → 454.9
drizzle-orm default 0.219 → 0.217 1.172 → 1.172 392.6 → 392.8
drizzle-orm TSRS_FAST=1 0.216 → 0.219 1.180 → 1.179 393.0 → 392.8
xstate-main default 0.317 → 0.316 1.391 → 1.393 336.6 → 336.9
xstate-main TSRS_FAST=1 0.319 → 0.315 1.400 → 1.396 337.6 → 336.5

@camc314
camc314 force-pushed the fix/lint-no-base-to-string-to-primitive branch from f927905 to 66a3c8c Compare November 29, 2026 18:54
@camc314
camc314 added this pull request to stack #1148 November 29, 2026 18:54
@camc314
camc314 added this pull request to the merge queue Nov 29, 2026
Merged via the queue into main with commit b31fc46 Nov 29, 2026
77 checks passed
@camc314
camc314 deleted the fix/lint-no-base-to-string-to-primitive branch November 29, 2026 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants